#include <iostream>

using namespace std;

#define ll long long

int main()
{
	ll n,m,x,y,z;
	cin>>n>>m>>x>>y>>z;
	ll num1 = (n % z) * (m % z) % z;
	ll num2 = x * y;
	ll result = 1;
	
    if (num2 == 0){
        cout<<0;
    } else {
	    while (num2){
		    if (num2 & 1){
			    result = (result * num1) % z;
		    }
		    num1 = (num1 * num1) % z;
		    num2 >>= 1;
	    }
        cout<<result;
    }
	return 0;
}

